﻿namespace Leetcode.N0933;
public class RecentCounter
{

    private readonly Queue<int> queue;
    public RecentCounter()
    {
        this.queue = new Queue<int>();
    }

    public int Ping(int t)
    {
        while (queue.Count > 0 && queue.Peek() < t - 3000)
        {
            queue.Dequeue();
        }
        queue.Enqueue(t);
        return queue.Count();
    }
}